/*
 * Copyright 2008 Daniel Freitas
 *
 * This file is part of Army Creator.
 * 
 * Army Creator is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Army Creator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Army Creator.  If not, see <http://www.gnu.org/licenses/>.
 */
package cheesr.model;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Cart implements java.io.Serializable {
    private List<Cheese> cheeses = new ArrayList<Cheese>();
    private Address billingAddress = new Address();

    public List<Cheese> getCheeses() {
        return Collections.unmodifiableList(cheeses);
    }

    public void clearCart() {
        cheeses = new ArrayList<Cheese>();
    }

    public void clearBillingAddress() {
        billingAddress = new Address();
    }

    public Address getBillingAddress() {
        return billingAddress;
    }

    public void setBillingAddress(Address other) {
        billingAddress = other;
    }

    public double getTotal() {
        double total = 0;

        for (Cheese cheese : cheeses) {
            total += cheese.getPrice();
        }

        return total;
    }

    public void add(Cheese selected) {
        cheeses.add(selected);
    }

    public void remove(Cheese selected) {
        cheeses.remove(selected);
    }

    private static final long serialVersionUID = 7658470522403753035L;
}